RegIni Control
RegIni (REG_INI) Control

Properties            Methods

Description

RegIni is a set of easy to use APIs which manipulate entries in Windows Initialisation (.INI) files and in the Registry. The control performs all the necessary error checking and can be used under Windows, Windows NT and Windows 95 platforms.

File Name

REG_INI.VBX

Remarks

.At runtime, the RegIni control is invisible.


Properties

The following table lists all the RegIni properties. There are two set of properties; those which are standard and those which are parameters for the special property Action. The Action property enables the user to carry out methods. Properties that apply specifically to this control, or require special consideration when used with it, are underlined. See the Visual Basic Language Reference or online Help for documentation of the remaining properties and events.

Standard Properties

Name

Special Properties

The special properties are not visible through the Properties Dialog Box when in design mode. They enable the user to perform methods by setting the Action property. The remaining properties provide the arguments to the Action.

Action

IniEntry

IniFname

IniSection

IniValue

RegEntry

RegKey

RegSubKey

RegValue

Status


Methods

RegIni Methods are implemented via the Action property.


Action Special Property
Action Special Property, RegIni Control

Description

Action is used to implement the RegIni methods and provides two sets of methods; Initialization file methods, known as INI methods, and registration methods, known as REG methods.

Usage

[form.]REGINI.Action[= setting]

Remarks

The table lists the Action Property settings together with their corresponding special properties that need to be set BEFORE setting the Action value.

Setting	Associated Properties	Description

RI_GETPROFILESTRING or 1	IniSection, IniEntry, IniFname	Retrieves the INI file entry value from the specified section in
the specified initialization file
(IniValue is set)

RI_WRITEPROFILESTRING or 2	IniSection, IniEntry, IniValue, IniFname	Sets the specified value for the specified entry in the
specified section for the specified initialization file

RI_CLEARPROFILE or 3	IniSection, IniEntry, IniFname	Clears INI file entries for the specified initialization file.
If IniEntry is empty, the entire specified section is deleted,
otherwise the specified entry in the specified section is deleted.

RI_REGGETKEY or 4	RegKey, RegSubKey, RegEntry	Retrieves the value for the specified entry in the registry
If RegEntry is empty, the [default] value is retrieved.
(RegValue property is set)

RI_REGSETKEY or 5	RegKey, RegSubKey	 	Sets the specified value for the specified entry in the registry
RegEntry , RegValue 	If RegEntry is empty, the [default] value is set.

RI_REGDELKEY or 6	RegKey, RegSubKey, RegEntry	Deletes the specifed entry from the registry
If RegEntry is empty, the entire subkey is deleted.

In order to use the RI.... settings for Action requires adding the file REG_INI.BAS to the project. This module defines these constants.

Data Type

Integer


IniEntry Special Property
IniEntry Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

IniEntry is the entry value for the specified INI file, IniFname.

Usage

[form.]REGINI. IniEntry[=inientry$]

Remarks

Refer to the Action property for implementation.

Data Type

String


IniFname Special Property
IniFname Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

IniFname is the iniitialization filename. The default value is WIN.INI

Usage

[form.]REGINI. IniFname[=inifname$]

Remarks

Refer to the Action property for implementation.

Data Type

String


IniSection Special Property
IniSection Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

IniSection is the section name for the specified INI file, IniFname.

Usage

[form.]REGINI. IniSection[=inisection$]

Remarks

Refer to the Action property for implementation.

Data Type

String


IniValue Special Property
IniValue Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

IniValue holds the value for the specified entry value, IniEntry, in the specified INI file, IniFname.

Usage

[form.]REGINI. IniValue[=inivalue$]

Remarks

Refer to the Action property for implementation.

Data Type

String


RegEntry Special Property
RegEntry Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

RegEntry is the name of the entry in the registry.

Usage

[form.]REGINI. RegEntry[=regentry$]

Remarks

Refer to the Action property for implementation.

Data Type

String


RegKey Special Property
RegKey Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

RegKey is the handle of the key, such as HKEY_CLASSES_ROOT.

Usage

 [form.]REGINI.RegKey[= number]

Remarks

Refer to the Action property for implementation.

Data Type

Integer


RegSubKey Special Property
RegSubKey Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

RegSubKey is the value of the subkey in the registry.

Usage

[form.]REGINI. RegSubKey[=regsubkey$]

Remarks

Refer to the Action property for implementation.

Data Type

String


RegValue Special Property
RegValue Special Property, RegIni Control

Example

Description

Special properties are used as parameters for the special Action property.

RegValue holds the value for the specified registry entry, RegEntry.

Usage

[form.]REGINI. RegValue[=regvalue$]

Remarks

Refer to the Action property for implementation.

Data Type

String


Status Special Property
Status Special Property, RegIni Control

Description

Special properties are used as parameters for the special Action property.

Status stores the return codes for all the RegIni methods.

Status values for INI methods
0  success
-1 if insufficient parameters or INI method fail

Status values for REG methods
0  success
-1 if insufficient parameters
1  bad db
2  bad key
3  can't open
4  can't read
5  can't write
6  out of memory
7  invalid parameter
8  access denied

Data Type

Integer


Initialization File Methods Example

Visual Basic Example

The following code shows how to use the INI methods.

RegIni1.IniFname = "REG.INI"
RegIni1.IniSection = "TEST"
RegIni1.IniEntry = "FILE1"

'Set regsitry value for FILE1
RegIni1.IniValue = "REG_INI.VBX"
RegIni1.Action = RI_WRITEPROFILESTRING

'Get entry value for FILE1
RegIni1.Action = RI_GETPROFILESTRING
MsgBox RegIni1.IniValue

'Clear Entry FILE1
RegIni1.Action = RI_CLEARPROFILE

'Clear section TEST
RegIni1.IniEntry = ""
RegIni1.Action = RI_CLEARPROFILE

'Check status value returned by RI_CLEARPROFILE
MsgBox "RI_CLEARPROFILE status " & CStr(RegIni1.Status)


Registry Methods Example

Visual Basic Example

The following code shows how to use the REG methods.

' Set AUTHOR entry value to FIS from subkey REG_INI
RegIni1.RegKey = HKEY_CLASSES_ROOT
RegIni1.RegSubKey = "REG_INI"
RegIni1.RegEntry = "AUTHOR"
RegIni1.RegValue = "FIS"
RegIni1.Action = RI_REGSETKEY

'Get AUTHOR key value
 RegIni1.Action = RI_REGGETKEY
MsgBox RegIni1.RegValue

'Delete registry key AUTHOR
RegIni1.Action = RI_REGDELKEY

' Delete whole subkey REG_INI by setting RegEntry to empty
RegIni1.RegEntry = ""
RegIni1.Action = RI_REGDELKEY

'Check status value returned by RI_REGDELKEY
MsgBox "RI_REGDELKEY status " & CStr(RegIni1.Status)